package cn.kgc.springbootday03.controller;

import cn.kgc.springbootday03.entity.Usr;
import cn.kgc.springbootday03.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: 课工场
 * @Version: v1.0  2023/5/25
 * @Description:
 */
@RestController
@RequestMapping("user")
public class UserController  {

    @Resource
    private UserService userService;

    @GetMapping
    public List<Usr> getList(){
        List<Usr> list = userService.list();
        return list;
    }


    @GetMapping("{id}")
    public Usr getOne(@PathVariable("id") Integer id){
        return  userService.getById(id);
    }


}
